Replace all occurrences of characters¶
re.sub(“[ ,.]”, “:”, S)
Replace all occurrences of space, comma, or dot with a colon.
import re
S = 'Python Exercises, PHP exercises.'
print(re.sub("[ ,.]", ":", S))
Output:
Python:Exercises::PHP:exercises: